package controller.cartp;

import com.alibaba.fastjson.JSON;
import com.zuche.framework.tradingPlatform.GroupType;
import com.zuche.framework.tradingPlatform.RequestParams;
import com.zuche.framework.utils.PropertiesReader;
import controller.constant.CarTpConstant;
import controller.remote.CartpRemoteClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 雷霆 on 2016/10/25.
 */
@Controller
@RequestMapping(value = "applyPay/",produces = "text/html;charset=utf-8")
public class ApplePayController {
    private String projectAddress;
    private static final Logger logger = LoggerFactory.getLogger(UnionPayRPCTestController.class);

    public ApplePayController() {
        this.projectAddress = PropertiesReader.getAppointPropertiesAttribute(
                "setting", "projectAddress", String.class);
    }


    @RequestMapping(value = "doApplyPay.do_")
    public static  Object doApplyPay(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.SOURCE_ID, CarTpConstant.SOURCE_ID);
        requestMap.put(RequestParams.GROUP_TYPE, GroupType.APPLE_PAY);
        requestMap.put(RequestParams.PAYER_ID, "5125079");
        requestMap.put(RequestParams.IDENTITY_TYPE, "0");
        requestMap.put("tp_customized_payType", "7");
        requestMap.put("tp_customized_memberId", "5125079");
        requestMap.put("tp_customized_countryCode", "");
        requestMap.put("tp_customized_uid", "6bc98ec3-5232-47d8-80f9-d1f161cfc8271477382977712");
        requestMap.put("tp_customized_memberMobile", "18677777777");
        requestMap.put("tp_customized_cid", "700330");
        requestMap.put("tp_customized_paySource", "");
        requestMap.put("tp_customized_deviceNo", "");
        requestMap.put("tp_customized_orderId", "");
        requestMap.put("tp_customized_deviceModel", "");
        requestMap.put("tp_account_type", "union");
        requestMap.put("tp_is_driver", "false");
        requestMap.put(RequestParams.GROUP_TYPE, "applePay");
        requestMap.put(RequestParams.BUSINESS_NAME, "2");
        requestMap.put(RequestParams.BUSINESS_ID, "DJP2257565501171");
        requestMap.put(RequestParams.BUSINESS_MONEY, "1");
        requestMap.put(RequestParams.CARD_TYPE, "0");
        requestMap.put(RequestParams.ASYNC_REPLY_URL, "http://mapiproxytest.10101111.com:9080/resource/m/ucar/cdms/pay/callback");
        requestMap.put(RequestParams.ASYNC_REPLY_URL, "http://mapiproxytest.10101111.com:9080/resource/m/ucar/cdms/pay/callback");


        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }
}
